package com.definity.toolkit.ui.widget;

import java.awt.Component;
import java.awt.Container;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public class WidgetUtils {

	public static Icon icon(String url) {
		return new ImageIcon(WidgetUtils.class.getClassLoader().getResource(url));
	}
	
	static Component find(Container c, String id) {
		Component[] components = c.getComponents();
		for (Component component : components) {
			if (id.equals(component.getName())) {
				return component;
			} else if (component instanceof Container) {
				Component child = find((Container) component, id);
				if (child != null)
					return child;
			}
		}
		
		return null;
	}
	
}
